#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct ListNode {
    int val;
    ListNode* next;
    ListNode(int x) : val(x), next(NULL) {}
};

class Solution {
public:
    ListNode* removeNthFromEnd(ListNode* head, int n) {
        ListNode* pn[2000], * p = head;
        int i = 0;
        pn[0] = p;
        while (p != NULL)
        {
            p = p->next;
            pn[++i] = p;
        }
        i -= n;
        if (i <= 0)return head->next;
        if (i > 0)pn[i - 1]->next = pn[i]->next;
        return head;
    }
};
int main()
{
    
}